﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace CommonLib
{
    public class JsonConfig
    {
        private static IConfigurationRoot configurationRoot;
        static JsonConfig()
        {
            if(configurationRoot == null)
            {
                var builder = new ConfigurationBuilder()
                    .SetBasePath(Directory.GetCurrentDirectory());
                builder.AddJsonFile("appsettings.json");
                configurationRoot = builder.Build();
            }
        }
        public static T GetJsonValue<T>(string key)
        {
            return configurationRoot.GetValue<T>(key);
        }
    }
}
